package org.spring.aop.aspectj;

import org.spring.aop.Pointcut;
import org.spring.aop.support.AbstractGenericPointcutAdvisor;
import org.spring.bean.exceptions.BeansException;
import org.spring.bean.factory.BeanFactory;
import org.spring.bean.factory.BeanFactoryAware;

/**
 * 可用于任何 AspectJ 切入点表达式的 Spring AOP Advisor。
 *
 * @author 李坤
 * @date 2022/4/19 17:03
 */
public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdvisor implements BeanFactoryAware {

    private final AspectJExpressionPointcut expressionPointcut;
    /**
     * bean 创建工厂
     */
    private BeanFactory beanFactory;

    public AspectJExpressionPointcutAdvisor(String expression) {
        expressionPointcut = new AspectJExpressionPointcut(expression);
    }

    @Override
    public Pointcut getPointcut() {
        return this.expressionPointcut;
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }

}
